home *** CD-ROM | disk | FTP | other *** search
-
-
-
- DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB)))) DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))
-
-
-
- NNNNAAAAMMMMEEEE
- opendir, readdir, telldir, seekdir, rewinddir, closedir, dirfd -
- directory operations (4.3BSD)
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
- ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ddddiiiirrrr....hhhh>>>>
-
- DDDDIIIIRRRR ****ooooppppeeeennnnddddiiiirrrr((((cccchhhhaaaarrrr ****ffffiiiilllleeeennnnaaaammmmeeee))));;;;
-
- ssssttttrrrruuuucccctttt ddddiiiirrrreeeecccctttt ****rrrreeeeaaaaddddddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
-
- lllloooonnnngggg tttteeeellllllllddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
-
- vvvvooooiiiidddd sssseeeeeeeekkkkddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp,,,, lllloooonnnngggg lllloooocccc))));;;;
-
- vvvvooooiiiidddd rrrreeeewwwwiiiinnnnddddddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
-
- vvvvooooiiiidddd cccclllloooosssseeeeddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
-
- iiiinnnntttt ddddiiiirrrrffffdddd((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))))
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- The inclusion of <_s_y_s/_d_i_r._h> selects the 4.3BSD versions of these
- routines. For the System V versions, include <_d_i_r_e_n_t._h>.
-
- _o_p_e_n_d_i_r opens the directory named by _f_i_l_e_n_a_m_e and associates a _d_i_r_e_c_t_o_r_y
- _s_t_r_e_a_m with it. _o_p_e_n_d_i_r returns a pointer to be used to identify the
- _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m in subsequent operations. The pointer NNNNUUUULLLLLLLL is returned
- if _f_i_l_e_n_a_m_e cannot be accessed, or if it cannot _m_a_l_l_o_c(3) enough memory
- to hold the whole thing.
-
- _r_e_a_d_d_i_r returns a pointer to the next directory entry. It returns NNNNUUUULLLLLLLL
- upon reaching the end of the directory or detecting an invalid _s_e_e_k_d_i_r
- operation.
-
- _t_e_l_l_d_i_r returns the current location associated with the named _d_i_r_e_c_t_o_r_y
- _s_t_r_e_a_m.
-
- _s_e_e_k_d_i_r sets the position of the next _r_e_a_d_d_i_r operation on the _d_i_r_e_c_t_o_r_y
- _s_t_r_e_a_m. The new position reverts to the one associated with the _d_i_r_e_c_t_o_r_y
- _s_t_r_e_a_m when the _t_e_l_l_d_i_r operation was performed. Values returned by
- _t_e_l_l_d_i_r are good only for the lifetime of the DIR pointer from which they
- are derived. If the directory is closed and then reopened, the _t_e_l_l_d_i_r
- value may be invalidated due to undetected directory compaction. It is
- safe to use a previous _t_e_l_l_d_i_r value immediately after a call to _o_p_e_n_d_i_r
- and before any calls to _r_e_a_d_d_i_r.
-
- _r_e_w_i_n_d_d_i_r resets the position of the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m to the
- beginning of the directory.
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB)))) DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))
-
-
-
- _c_l_o_s_e_d_i_r closes the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m and frees the structure
- associated with the DIR pointer.
-
- _d_i_r_f_d returns the integer file descriptor associated with the named
- _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m, see open(2).
-
- Sample code that searches a directory for entry ``name'':
-
- len = strlen(name);
- dirp = opendir(".");
- if (dirp == NULL) {
- return NOT_FOUND;
- }
- while ((dp = readdir(dirp)) != NULL) {
- if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
- closedir(dirp);
- return FOUND;
- }
- }
- closedir(dirp);
- return NOT_FOUND;
-
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- open(2), close(2), read(2), lseek(2), directory(3C)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-